﻿
Public Class frmMain
    Implements IModuleHost

    Private Sub frmMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        WorkItemFileHistory1.ModuleHost = Me
        WorkItemFieldHistory1.ModuleHost = Me
        FileWorkItemHistory1.ModuleHost = Me
    End Sub

    Public Function GetServerAddress() As String Implements IModuleHost.GetServerAddress
        Return txtServer.Text
    End Function

    Public Function GetCredentials() As System.Net.ICredentials Implements IModuleHost.GetCredentials
        If cmbAuthType.Text = "Windows" Then
            Return System.Net.CredentialCache.DefaultCredentials
        ElseIf cmbAuthType.Text = "Username/Pwd" Then
            Dim domain As String = txtDomain.Text
            Dim username As String = txtUsername.Text
            Dim password As String = txtPassword.Text
            Return New System.Net.NetworkCredential(username, password)
        Else
            Throw New Exception("Invalid authentication type")
        End If

    End Function

    Private Sub cmbAuthType_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbAuthType.TextChanged
        Dim cmb As ComboBox = sender
        Dim b As Boolean = cmb.Text = "Username/Pwd"
        txtDomain.Enabled = b
        txtUsername.Enabled = b
        txtPassword.Enabled = b
    End Sub

End Class


